@extends('simple-h5.views.layout')
@section('content')
    <link rel="stylesheet" href="/themes/simple-h5/static/css/list.css?v=1.1">
    <script src="/themes/simple-h5/static/js/list.js"></script>
    <div class="banner">
        <img src="{{$category_info['thumb']}}" />
    </div>

    <div class="cat-container">
        <div class="cat-wrapper">
            @php $category_list = cms_category_list(['order'=>'display_order desc,id desc','where'=>'type=1']) @endphp
            @foreach ($category_list as $item)
                <div class=" @if ($item['id']==$cid) cat-active @endif cat-item">
                    <a href="/product/list?cid={{$item['id']}}">{{$item['name']}}</a>
                </div>
            @endforeach
        </div>
    </div>
    <div class="img-list clearfix">
        @foreach ($list as $item)
            <a href="/product/detail?id={{$item['id']}}" class="img-item">
                <div>
                    <img src="{{$item->thumb}}" />
                </div>
                <div class="img-item-text">
                    {{$item->name}}
                </div>
                <div class="img-item-price">
                    {{$item->price}}
                </div>
            </a>
        @endforeach
    </div>

    @php
        $totalItem = $list->total();
        $currentPage = $list->currentPage();
        $totalPage = ceil($totalItem/$list->perPage());
    @endphp
    @if ($totalItem>=8)
        <div class="page-ctrl">
            @if ($currentPage==1)
                <a class="prev-page disabled btn-dis">上一页</a>
            @else
                <a href="/product/list?cid={{$category_info['id']}}&page={{$currentPage-1}}" class="prev-page">上一页</a>
            @endif

            <span class="current-page">{{$currentPage}}</span><span>/</span><span class="total-page">{{$totalPage}}</span>

            @if($currentPage==$totalPage)
                <a class="next-page disabled btn-dis">下一页</a>
            @else
                <a href="/product/list?cid={{$category_info['id']}}&page={{$currentPage+1}}" class="next-page">下一页</a>
            @endif

        </div>
    @endif

@endsection
